package com.fjec.common.setting;

import org.apache.commons.collections.MapUtils;

import java.util.HashMap;
import java.util.Map;

public class Setting extends HashMap<String, Object> {

    public static final String SYSTEM_SETTING_KEY = "fjec:system:setting:key";
    /**
     * 水果零售佣金=3%
     */
    private static final String FRUITS_RETAIL_COMMISSION_KEY = "fruits_retail_commission";
    /**
     * 水果批量采购=1.5%
     */
    private static final String FRUITS_BATCH_COMMISSION_KEY = "fruits_batch_commission";
    /**
     * 礼物佣金=30%
     */
    private static final String EXCHANGE_GIFT_PERCENT = "exchange_gift_percent";

    /**
     * 订单最大金额限制=500000分
     */
    private static final String MAX_ORDER_AMOUNT_KEY = "max_order_amount";

    /**
     * 用户兑换礼物最小钱数
     */
    private static final String EXCHANGE_GIFT_MIN = "exchange_gift_min";
    /**
     * 用户兑换礼物最大钱数
     */
    private static final String EXCHANGE_GIFT_MAX = "exchange_gift_max";

    public Setting(Map<String, Object> map) {
        this.putAll(map);
    }

    /**
     * 水果零售佣金
     *
     * @return
     */
    public String getFruitsRetailCommission() {
        return MapUtils.getString(this, FRUITS_RETAIL_COMMISSION_KEY);
    }

    /**
     * 水果批量采购佣金
     *
     * @return
     */
    public String getFruitsBatchCommission() {
        return MapUtils.getString(this, FRUITS_BATCH_COMMISSION_KEY);
    }

    /**
     * 兑换礼物价格比例
     *
     * @return
     */
    public String getExchangeGiftPercent() {
        return MapUtils.getString(this, EXCHANGE_GIFT_PERCENT);
    }

    /**
     * 订单最大金额限制=500000分
     */
    public String getMaxOrderAmount() {
        return MapUtils.getString(this, MAX_ORDER_AMOUNT_KEY);
    }

    /**
     * 获取用户兑换礼物金额最小值
     *
     * @return
     */
    public Integer getExchangeGiftMin() {
        Integer result = MapUtils.getInteger(this, EXCHANGE_GIFT_MIN);
        return result;
    }

    /**
     * 获取用户兑换礼物金额最大值
     *
     * @return
     */
    public Integer getExchangeGiftMax() {
        Integer result = MapUtils.getInteger(this, EXCHANGE_GIFT_MAX);
        return result;
    }
}
